﻿/*
 * (c) Stefan Bojarovski 2010
 * */
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASTBuilder
{
    class IntegerNode : NodesCollection, IArithmeticNode
    {
        private LexemeType lexType = LexemeType.CONST;
        private int Value;
        private bool UMinus;

        public IntegerNode(int someValue)
        {
            Value = someValue;
        }
        public int getValue()
        {
            return Value;
        }
        public LexemeType getLexemeType()
        {
            return lexType;
        }
        public void setNegative()
        {
            UMinus = true;
            Value *= (-1);
        }
        public IArithmeticNode getFirst() { return this; }
        public IArithmeticNode getSecond() { return this; }
        public void printNode(String parentLevel, StreamWriter someStream)
        {
            someStream.WriteLine(parentLevel + " " + "Constant: " + Value);
        }
        public List<Command> evalNode(ref Direction next,
                                        ref Dictionary<String, Pair<IdentifierType, object>> Environment)
        {
            List<Command> intResult = new List<Command>();
            intResult.Add(new Command(CommandType.EVALUABLE, null, Value));
            return intResult;
        }
    }
}
